<?php
namespace application\datatypes;
use application\datatypes\DataType;
use application\utilities\Utility;
class Timestamp extends DataType {
	public static $name = 'Timestamp';
	public static $fields = array(array('columnType'=>'TIMESTAMP'));
	public static $displayParams = array(
		array(
			'label'=>'Format',
			'name'=>'format',
			'type'=>'text',
			'defaultValue'=>'m/d/Y g:ia'
		)
	);
	
	public static function validate($field, $data, $results) {
		return $results;
	}
	
	public static function display($formElements) {
		if($formElements) {
			echo $formElements['elements']['element'];
		}
	}
	
	public static function prepareData($field, $data, $params) {
		$format = $params['format'];
		$date = $data[$field->cf_column];
		if(!$format) $format = 'm/d/Y g:ia';
		return date($format, strtotime($date));
	}
	
	public static function build($field, $row) {

		return FALSE;
	
	}
	
	public static function editForm($field) {
		?>
		<div class="box-content">
			You can't edit an automatic field.
		</div>
			<?php
	}
	
}
?>